package com.demo.scheduler;

import com.alibaba.fastjson.JSON;
import com.demo.esper.IEsper;
import com.demo.model.common.DemoConstant;
import com.demo.model.dto.DemoEsperEvent;
import com.demo.model.dto.DemoEsperResult;
import com.github.ltsopensource.spring.tasktracker.JobRunnerItem;
import com.github.ltsopensource.spring.tasktracker.LTS;

import javax.annotation.Resource;

@LTS
public class LTSTask {

    @Resource
    private IEsper iEsper;

    @JobRunnerItem(shardValue = "springbootSampleJob")
    public void testEsper() {
        DemoEsperEvent event = new DemoEsperEvent();
        event.setAge(9);
        Long eventId = iEsper.sendEvent(DemoConstant.DEMO_EVENT_TYPE_NAME, DemoConstant.RULE_GROUP_NAME, event);
        System.out.println("LTSTask testEsper, 结果: " + JSON.toJSONString(iEsper.getEsperResult(eventId, DemoEsperResult.class)));
    }


}
